@extends("admin.base")
@section("page")
    <html>
    <style>
        @font-face {
            font-family: "ALKATIP Asliya";
        }
    </style>
    <body>
    <h1 align="center">管理页面</h1>
    <div class="row col-12">
        <div class="card">
            <div class="card-body">
                <a href="addtil">
                    <button class="btn-primary " style="width: 50px;height: 30px">添加</button>
                </a>

                <div class="table-responsive">
                    <table class="table mb-0" style="text-align: center;font-family: 'ALKATIP Asliya'" align="center">
                        <tr>
                            <td>id</td>
                            <td>中文名称</td>
                            <td>维吾尔文名称</td>
                            <td>排序</td>
                            <td>created_at</td>
                            <td>updated_at</td>
                            <td>操作</td>


                        @foreach($data as $dt)
                            <tr class="table-success">
                                <td scope="row">{{$dt->id}}</td>
                                <td>{{$dt->til_ch}}</td>
                                <td>{{$dt->til_uy}}</td>
                                <td>{{$dt->order}}</td>
                                <td>{{$dt->created_at}}</td>
                                <td>{{$dt->updated_at}}</td>
                                <td>
                                    <a href="tilupdate?id={{$dt->id}}">
                                        <button
                                            style="background-color: orangered;border: none;border-radius: 5px;height: 30px;width: 50px;outline: none;">
                                            编辑
                                        </button>
                                    </a>
                                    <a>
                                        <button onclick="del({{$dt->id}})"
                                                style="background-color: orangered;border: none;border-radius: 5px;height: 30px;width: 50px;outline: none;">
                                            删除
                                        </button>
                                    </a>

                                </td>
                            </tr>
                        @endforeach
                    </table>

                </div>

            </div>
        </div>
    </div>
    </body>
    </html>
@endsection

@section("scripts")
    <style>
        .swal-footer {
            text-align: center;
            padding-top: 13px;
            margin-top: 13px;
            padding: 13px 16px;
            border-radius: inherit;
            border-top-left-radius: 0;
            border-top-right-radius: 0;
        }
    </style>
    <script>
        function del(id) {
            swal({
                title: "确认操作",
                text: "你真的要删除吗",
                icon: "warning",
                buttons: ["取消", "删除"],
            }).then((willDelete)=>{
                if (willDelete) {
                    $.ajax({
                        url: "http://dil.aynakedu.com/tildelete",    //请求的url地址
                        dataType: "json",   //返回格式为json
                        async: true,//请求是否异步，默认为异步，这也是ajax重要特性
                        headers: {'X-CSRF-TOKEN': '{{csrf_token()}}'},
                        data: {"id": id},    //参数值
                        type: "GET",   //请求方式
                        success: function (req) {
                            if (req.err == 0) {
                                swal({
                                    title: "操作成功",
                                    text: req.title,
                                    icon: "success",
                                    button: "知道了",
                                });
                                setTimeout(function () {
                                    location.reload();
                                }, 2000)
                            }
                        }, error: function (err) {
                            //请求出错处理
                        }
                    });
                }else{

                }
            });


        }
    </script>
@endsection

